package zhieasy.cn.service.forum.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import zhieasy.cn.model.forum.ForumLikeUser;
import zhieasy.cn.persistence.mapper.forum.ForumLikeUserMapper;
import zhieasy.cn.service.forum.ForumLikeUserService;

/**
 * @author DaHang
 * @date 2020/8/30 0:42
 */
@Service
public class ForumLikeUserServiceImpl extends ServiceImpl<ForumLikeUserMapper, ForumLikeUser> implements ForumLikeUserService {

    @Autowired
    ForumLikeUserMapper forumLikeUserMapper;

    @Override
    public boolean isLikeForum(int forumId, String openId) {
        QueryWrapper<ForumLikeUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",forumId);
        queryWrapper.eq("open_id",openId);
        ForumLikeUser forumLikeUser = forumLikeUserMapper.selectOne(queryWrapper);
        if (forumLikeUser == null) {
            return false;
        }
        return true;
    }
}
